# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(myNpmLib)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)
# djvucore start
add_library(djvucore STATIC
        ${NATIVERENDER_ROOT_PATH}/libdjvu/JB2EncodeCodec.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/JB2Image.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/JPEGDecoder.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/MMRDecoder.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/MMX.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/UnicodeByteStream.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/XMLParser.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/XMLTags.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/ZPCodec.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/Arrays.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/atomic.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/BSByteStream.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/BSEncodeByteStream.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/ByteStream.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DataPool.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/ddjvuapi.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/debug.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVmDir.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVmDir0.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVmDoc.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVmNav.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuAnno.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuDocEditor.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuDocument.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuDumpHelper.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuErrorList.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuFile.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuFileCache.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuGlobal.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuGlobalMemory.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuImage.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuInfo.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuMessage.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuMessageLite.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuNavDir.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuPalette.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuPort.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuText.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/DjVuToPS.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GBitmap.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GContainer.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GException.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GIFFManager.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GMapAreas.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GOS.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GPixmap.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GRect.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GScaler.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GSmartPointer.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GString.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GThreads.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GUnicode.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/GURL.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/IFFByteStream.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/IW44EncodeCodec.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/IW44Image.cpp
        ${NATIVERENDER_ROOT_PATH}/libdjvu/miniexp.cpp)
target_include_directories(djvucore PUBLIC ${NATIVERENDER_ROOT_PATH}/libdjvu/)

target_compile_definitions(djvucore PRIVATE -DHAVE_PTHREAD -DNO_LIBGCC_HOOKS -DHAVE_STDINT_H -DHAVE_NAMESPACES -DHAVE_STDINCLUDES)
target_compile_definitions(djvucore PRIVATE -DHAS_WCHAR -DHAVE_WCHAR_H -DHAVE_MBSTATE_T -DHAS_MBSTATE)
target_compile_definitions(djvucore PRIVATE -DUNIX)
#djvucore end

add_library(djvulibre SHARED ${NATIVERENDER_ROOT_PATH}/napi_init.cpp)

target_include_directories(djvulibre PUBLIC ${NATIVERENDER_ROOT_PATH}/libdjvu/)
target_compile_definitions(djvulibre PRIVATE -DORION_FOR_ANDROID)
target_compile_options(djvulibre PRIVATE -fexceptions -frtti)

target_link_libraries(djvucore PUBLIC libace_napi.z.so)
target_link_libraries(djvulibre PUBLIC libace_napi.z.so)
target_link_libraries(djvulibre PUBLIC djvucore)